4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 namespace Microsoft
.JScript
{
20 public class RegExpPrototype
: JSObject
{
21 internal static readonly RegExpPrototype ob
= new RegExpPrototype(ObjectPrototype
.ob
);
22 internal static RegExpConstructor _constructor
;
24 internal RegExpPrototype(ObjectPrototype parent
)
26 //this.constructor is given a value by the proper constructor class
29 [JSFunctionAttribute(JSFunctionAttributeEnum
.HasThisObject
, JSBuiltin
.RegExp_compile
)]
30 public static RegExpObject
compile(Object thisob
, Object source
, Object flags
) {
31 RegExpObject regExpObject
= thisob
as RegExpObject
;
32 if (regExpObject
== null)
33 throw new JScriptException(JSError
.RegExpExpected
);
34 return regExpObject
.compile(
35 source
== null || source
is Missing
? "" : Convert
.ToString(source
),
36 flags
== null || flags
is Missing
? "" : Convert
.ToString(flags
));
39 public static RegExpConstructor constructor
{
41 return RegExpPrototype
._constructor
;
45 [JSFunctionAttribute(JSFunctionAttributeEnum
.HasThisObject
, JSBuiltin
.RegExp_exec
)]
46 public static Object
exec(Object thisob
, Object input
) {
47 RegExpObject regExpObject
= thisob
as RegExpObject
;
48 if (regExpObject
== null)
49 throw new JScriptException(JSError
.RegExpExpected
);
50 if (input
is Missing
&& !regExpObject
.regExpConst
.noExpando
)
51 input
= regExpObject
.regExpConst
.input
;
52 return regExpObject
.exec(Convert
.ToString(input
));
55 [JSFunctionAttribute(JSFunctionAttributeEnum
.HasThisObject
, JSBuiltin
.RegExp_test
)]
56 public static bool test(Object thisob
, Object input
) {
57 RegExpObject regExpObject
= thisob
as RegExpObject
;
58 if (regExpObject
== null)
59 throw new JScriptException(JSError
.RegExpExpected
);
60 if (input
is Missing
&& !regExpObject
.regExpConst
.noExpando
)
61 input
= regExpObject
.regExpConst
.input
;
62 return regExpObject
.test(Convert
.ToString(input
));
65 [JSFunctionAttribute(JSFunctionAttributeEnum
.HasThisObject
, JSBuiltin
.RegExp_toString
)]
66 public static String
toString(Object thisob
) {
67 RegExpObject regExpObject
= thisob
as RegExpObject
;
68 if (regExpObject
== null)
69 throw new JScriptException(JSError
.RegExpExpected
);
70 return regExpObject
.ToString();